#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int ans,tt;
double n,m,l,V;
double d[MAXN],v[MAXN],a[MAXN];
struct node{
    int val;
    vector<int> g;
} p[MAXN];
bool vis[MAXN],b[MAXN];
bool cmp(node u,node v)
{
    return u.g.size()>v.g.size();
}
int f(double x)
{
    int l=0,r=n+1;
    while(l+1<r)
    {
        int mid=(l+r)>>1;
        if((double)p[mid].val>x) r=mid;
        else l=mid;
    }
    return r;
}
void dfs(int step,int num)
{
    if(step>m)
    {
        int cnt=tt;
        for(int i=1;i<=m;i++)
        {
            if(vis[i])
            {
                for(int j=0;j<p[i].g.size();j++)
                {
                    if(!b[j]) cnt--;
                    b[j]=1;
                }
            }
        }
        if(cnt==0)
            if(num<ans) ans=num;
        return ;
    }
    vis[step]=0;
    dfs(step+1,num);
    vis[step]=1;
    dfs(step+1,num+1);
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        ans=n;
        for(int i=1;i<=m;i++) p[i].g.clear();
        memset(b,0,sizeof(b));
        scanf("%lf%lf%lf%lf",&n,&m,&l,&V);
        for(int i=1;i<=n;i++)
        {
            scanf("%lf%lf%lf",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&p[i].val);
        }
        for(int i=1;i<=n;i++)
        {
            if(v[i]<=V&&a[i]<=0) continue;
            if(a[i]==0)
            {
                if(v[i]<=V) continue;
                int j=f(d[i]);
                //cout<<i<<" "<<j<<endl;
                if(j<=m) tt++;
                for(;j<=m;j++) p[j].g.push_back(i);
            }
            else if(a[i]>0)
            {
                if(v[i]<=V) d[i]+=(V*V-v[i]*v[i])/(2*a[i]);
                int j=f((double)ceil(d[i]));
                //cout<<i<<" "<<j<<endl;
                if(j<=m) tt++;
                for(;j<=m;j++) p[j].g.push_back(i);
            }
            else
            {
                int j=f(d[i]),ed=f((double)floor(d[i]+(V*V-v[i]*v[i])/(2*a[i])));
                //cout<<i<<" "<<j<<" "<<ed<<endl;
                if(j<=ed) tt++;
                for(;j<=ed;j++) p[j].g.push_back(i);
            }
        }
        sort(p+1,p+(int)m+1,cmp);
        dfs(1,0);
        cout<<tt<<" "<<n-ans<<endl;
    }
    return 0;
}
